<input type="hidden" id="update_album_status" value="<?php echo $this->session->flashdata('update_album_status'); ?>" />
<input type="hidden" id="update_album_msg" value="<?php echo $this->session->flashdata('update_album_msg'); ?>" />
<script type="text/javascript">
  $(document).ready(function() {
    $("img.album_item_thumb").lazy();
    var update_album_status = $.trim($('#update_album_status').val());
    var update_album_msg = $.trim($('#update_album_msg').val());
    if (update_album_msg) {
      toastr.error(update_album_msg);
      return false;
    } else if (update_album_status == 2) {
      toastr.error('Error occured. Try again !');
      return false;
    }
  });
</script>

<div class="page" style="min-height: 500px;">
  <div class="page-container">
    <div class="container">
      <div class="row">
        <div class="span12 header">
          <div class="btn-group" style="float: right; margin-bottom: 10px;">
            <a href="<?php echo base_url('album/' . $album_id); ?>" class="btn">View album</a>
          </div>
          <h4>Update album</h4>
        </div>
        <div class="span6">
          <form method="post" action="<?php echo base_url('album/update/' . $album_data['album_id'] . '/upd'); ?>" class="form-horizontal" onsubmit="return confirm_action('Save changes ?');" enctype="multipart/form-data">
            <input type="hidden" name="csrf_token" value="<?php echo set_csrf_token(); ?>"/>
            <div class="control-group">
              <label class="control-label">Album name </label>
              <div class="controls">
                <input name="album_name" id="album_name" type="text" style="width: 150%;" placeholder="Enter album name (250)" value="<?php echo $album_data['album_name']; ?>" maxlength="250"/>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Add photos / videos </label>
              <div class="controls">
                <input name="album_image[]" id="album_image" type="file" multiple="multiple" accept="image/*"/>
              </div>
            </div>
            <div class="control-group">
              <label class="control-label">Publish album</label>
              <div class="controls">
                <input value="1" style="vertical-align: middle;" name="album_status" id="album_status" type="checkbox" <?php if ($album_data['album_status'] == 1) { ?> checked="checked" <?php } ?>/>
              </div>
            </div>
            <div class="control-group"> 
              <div class="controls">
                <button type="submit" class="btn" onclick="return validate_album();">Update</button>
                <span id="loading_div" style="display: none; color: #0088CC">
                  <img src="<?php echo site_url('assets/img/loading_animation.gif'); ?>"/>
                  &nbsp;Please wait ...&nbsp;
                </span>
              </div>
            </div>
            <div class="control-group">
              <div class="controls">
                <div class="text-info" style="width: 500px;">
                  # You can choose multiple photos or videos by holding ctrl or shift key<br/>
                  # And can select maximum <b><?php echo ini_get('max_file_uploads'); ?></b> files of total size <b><?php echo ini_get('post_max_size'); ?></b><br/>
                </div>
              </div>
            </div>
          </form>
        </div>
        <div class="clearfix"></div>
        <div class="container divide"></div>
        <div class="span">
          <?php if (!empty($album_data['album_photos']) && is_array($album_data['album_photos'])) { ?>
            <form method="post" action="<?php echo base_url('album/update/' . $album_data['album_id'] . '/del'); ?>" class="form-horizontal" onsubmit="return confirm_action('Delete selected items ?');">
              <input type="hidden" name="csrf_token" value="<?php echo set_csrf_token(); ?>"/>
              <div class="control-group">
                <label class="control-label">Delete photos / videos </label>
                <div class="controls">
                  <ul class="grid">
                    <?php foreach ($album_data['album_photos'] as $album_photo) { ?>
                      <li>
                        <a>
                          <img class="album_item_thumb" src="<?php echo base_url('assets/img/loading_black.gif'); ?>" data-src="<?php echo base_url('assets/albums/' . $album_data['album_id'] . '/' . substr($album_photo['photo_file'], 0, 32) . '_thumb.jpg'); ?>">
                          <input class="checkbox delete_photo_ids" name="delete_photo_ids[]" value="<?php echo $album_photo['photo_id']; ?>" style="position: absolute; margin-top: 25px; margin-left: -5px;" type="checkbox" />
                          <?php if ($album_photo['photo_video_type'] == 2) { ?>
                            <i class="icon-large icon-film" style="position: absolute; margin-left: -47px;"></i>
                          <?php } ?>
                        </a>
                      </li>
                    <?php } ?>
                  </ul>
                </div>
              </div>
              <div class="control-group"> 
                <div class="controls">
                  <button type="submit" class="btn" onclick="return validate_delete();">Delete</button>
                </div>
              </div>
              <div style="color: #CCC; width: 500px; margin-left: 175px;">
                # Select the photos / videos to delete from album<br/>
              </div>
            </form>
          <?php } else { ?>
            No photos / videos in this album !
          <?php } ?>
        </div>
      </div>
    </div>
  </div>
</div>